<template>
    <example :template-code="templateString">
        <template #describe>
            <t :id="`${$t('基础示例')}`">{{ $t('基础示例') }}</t>
            <li>
                <span class="s-code">start</span>、
                <span class="s-code">end</span>、
                <span class="s-code">step</span>分别可以设置起始时间、结束时间、以及时间步长（间隔时间）
            </li>
            <li>
                <span class="s-code">minTime</span>、
                <span class="s-code">maxTime</span>可以用于限制时间选择的区间
            </li>
            <li>
                <span class="s-code">format</span>可以设置输入框内展示值的格式化规则
            </li>
            <li>
                <span class="s-code">valueFormat</span>可以设置<span class="s-code">v-model</span>绑定值的格式化规则
            </li>
        </template>
        <div style="color:#999;">
            <div style="width: 300px;">
                <p style="color:#666;">普通用法：</p>
                <sib-item v-model="value1" :props="props1" @change="change"></sib-item>
                <p>当前选择的是：{{ value1 }}</p>
            </div>
            <div style="width: 300px;">
                <p style="color:#666;">设置起始时间、结束时间、以及时间步长：</p>
                <sib-item v-model="value2" :props="props2" @change="change"></sib-item>
                <p>当前选择的是：{{ value2 }}</p>
            </div>
            <div style="width: 300px;">
                <p style="color:#666;">限制时间选择区间：</p>
                <sib-item v-model="value3" :props="props3" @change="change"></sib-item>
                <p>当前选择的是：{{ value3 }}</p>
            </div>
            <div style="width: 300px;">
                <p style="color:#666;">格式化绑定值和展示值：</p>
                <sib-item v-model="value4" :props="props4" @change="change"></sib-item>
                <p>当前选择的是：{{ value4 }}</p>
            </div>
        </div>
    </example>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value1 = ref('12:30');
        const props1 = reactive({
            type: 'droptime',
        });

        const value2 = ref(null);
        const props2 = reactive({
            type: 'droptime',
            start: '08:00',
            end: '16:00',
            step: '00:10',
        });

        const value3 = ref('09:00');
        const props3 = reactive({
            type: 'droptime',
            minTime: '08:00',
            maxTime: '10:30',
        });

        const value4 = ref(null);
        const props4 = reactive({
            type: 'droptime',
            format: 'YYYY HH点mm分',
        });

        const change = (data) => {
            console.log('data: ', data);
        };

        return {
            value1,
            props1,
            value2,
            props2,
            value3,
            props3,
            value4,
            props4,
            change,
            templateString: `<template>
    <div>
        <p>普通用法：</p>
        <sib-item v-model="value1" :props="props1" @change="change"></sib-item>
        <p>当前选择的是：{{ value1 }}</p>
    </div>
    <div>
        <p>设置起始时间、结束时间、以及时间步长：</p>
        <sib-item v-model="value2" :props="props2" @change="change"></sib-item>
        <p>当前选择的是：{{ value2 }}</p>
    </div>
    <div>
        <p>限制时间选择区间：</p>
        <sib-item v-model="value3" :props="props3" @change="change"></sib-item>
        <p>当前选择的是：{{ value3 }}</p>
    </div>
    <div>
        <p>格式化绑定值和展示值：</p>
        <sib-item v-model="value4" :props="props4" @change="change"></sib-item>
        <p>当前选择的是：{{ value4 }}</p>
    </div>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value1 = ref('12:30');
        const props1 = reactive({
            type: 'droptime',
        });

        const value2 = ref(null);
        const props2 = reactive({
            type: 'droptime',
            start: '08:00',
            end: '16:00',
            step: '00:10',
        });

        const value3 = ref('09:00');
        const props3 = reactive({
            type: 'droptime',
            minTime: '08:00',
            maxTime: '10:30',
        });

        const value4 = ref(null);
        const props4 = reactive({
            type: 'droptime',
            format: 'YYYY HH点mm分',
        });

        const change = (data) => {
            console.log('data: ', data);
        };

        return { value1, value2, value3, value4, props1, props2, props3, props4, change };
    },
};
<\/script>`,
        };
    },
};
</script>
